/**
 * 
 */

	function showDiferent(){
		try{
			var data = window.thirdPartyFormAPI.getFormData();
			//关键人员简历从表第一行开始时间控件不可以编辑
			if(data.formData.tableInfo.formmain.tableName == "formmain_0717"){
				data.formsons.front_formson_4.records["0"].lists.field0018.auth="browse";
			}
			var _qiangsSeepManager = new qiangsSeepManager();
			_qiangsSeepManager.getDifferentField(data.formData.content.contentTemplateId+"", 
				data.formData.content.contentDataId+"", 
				{
					success: function(returnVal){
						if(returnVal != null){
							var delData = new Array();
							for(var i=0; i < returnVal.length; i++){
								var obj = returnVal[i];
								if(obj.select){
									if($("#"+obj.select).find(obj.find).find("span[style*='red']").length == 0){
										$("#"+obj.select).find(obj.find).append(obj.value);
									}
								} else if($("#tableName-" + obj.front)){
									/**var data = window.thirdPartyFormAPI.getFormData();
									var total = data.formsons['front_formson_' + obj.index].records.length;							
									var params = {
										tableName : tableName,
										isFormRecords : false,
										chooseRecords : {
											tableName : total-1
										},
										callbackFn : function () {
												self.showDiferentAddRows(obj, params)
										}
									};
									window.thirdPartyFormAPI.insertFormsonRecords(params);
									if(total != tr.length || tr.length == 0){
										continue;
									}*/
									$("Section .formson").find("Section [class^=formson_]").find("TR").each(function (){
										if($(this).attr("isdel") == obj.sonId){
											$(this).remove();
										}
									});
									delData.push(obj);
								}
							}
							for(var d=0; d<delData.length; d++){
								var obj = delData[d];
								var tableName = obj.table;
								var tr = $("Section ."+tableName).find("TR.is-detailshover");
								var sourceTr = tr[tr.length - 1];
								var copys = [];
								var newIndex = 0;
								for(var index = 0; index < tr.length; index++){
								//$(tr).each(function(index, obj, sourceTr, copys){
									if($(sourceTr).attr("data-record-id") == $(tr[index]).attr("data-record-id")){
										var copy;
										if($(tr[index]).attr("data-record-id") == ""){
											copy = $(sourceTr).clone();
										} else {
											copy = $(tr[index]).clone();
										}
										$(copy).attr("data-record-id", obj.sonId);
										$(copy).attr("isdel",obj.sonId);
										$(copy).find("div[id*='_id']").each(function(){
											if($(this).attr("id").indexOf("_add") == 0){
												$(this).attr("id", $(this).attr("id")+"_add");
											}
										});
										$(copy).find("div[id*='_id']").find("div[class*='_browse']").each(function(){
											$(this).text("");
										});
										$(copy).find("div[id*='_id']").find("input").each(function(){
											$(this).remove();
										});
										$(copy).find("div[id*='_id']").find("radio").each(function(){
											$(this).remove();
										});
										$(copy).find("div[id*='_id']").find("checkbox").each(function(){
											$(this).remove();
										});
										$(copy).find("div[id*='_id']").find("select").each(function(){
											$(this).remove();
										});
										$(copy).find("div[id*='_id']").find("textarea").each(function(){
											$(this).remove();
										});
										for(var j = 0; j < Object.keys(obj).length; j++){
											//if(Object.keys(obj)[j] != 'front' && Object.keys(obj)[j] != 'table'){
											if(Object.keys(obj)[j].indexOf('field') == 0){
												$(copy).find("div[id^='"+Object.keys(obj)[j]+"']").find("div[class*='_browse']").empty();
												
												$(copy).find("div[id^='"+Object.keys(obj)[j]+"']").find("div[class*='_browse']").text(obj[Object.keys(obj)[j]]);
											}
										}
										copys[newIndex] = copy;
										newIndex++;
										if($(tr[index]).attr("data-record-id") == ""){
											break;
										}
									}
								}
								for(var k = copys.length - 1; k >= 0; k--){
									$(sourceTr).after(copys[k]);
								}
							}
						}
					}
				});
		} catch(e){}
	}

	function showDiferentAddRows(data, params) {
		var formData = window.thirdPartyFormAPI.getFormData();
		var total = formData.formsons.front_formson_1.records.length;
		for(var i = 0; i < Object.keys(data).length; i++){
			if(Object.keys(data)[i] != 'index' && Object.keys(data)[i] != 'table'){
				try{
					//formData.formsons['front_formson_'+data.index].records[total-1+""].lists[Object.keys(data)[i]].value=data[Object.keys(data)[i]];
					formData.formsons['front_formson_'+data.index].records[total-1+""].lists[Object.keys(data)[i]].showValue=data[Object.keys(data)[i]];
				} catch(e){}
			}
		}
		/**
		formData.formsons.front_formson_1.records[total-1].lists.field0016.value = data[0].name;
		formData.formsons.front_formson_1.records[total-1].lists.field0018.value = data[0].elementId;
		//data.formsons['front_formson_'+adress.index].records[total-1+""].lists[Object.keys(adress)[0]]
		data.splice(0, 1);
		if(data.length >= 1){
			params.chooseRecords = {
									'formson_0033' : total-1
								};
			window.thirdPartyFormAPI.insertFormsonRecords(params);
		}
		*/
	}
window.setTimeout(showDiferent, 1*1000);